﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Monk.Site.Extentions
{
    public static class RazorExtention
    {
        public static MvcHtmlString Submit(this HtmlHelper helper, string id, string text = "提交", object htmlAttributes = null)
        {
            TagBuilder builder = new TagBuilder("input");

            builder.IdAttributeDotReplacement = "-";
            builder.GenerateId(id);

            builder.MergeAttributes(new Dictionary<string, string> {
                {"type", "submit" },
                {"value",text }
            });
            builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));

            return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing));
        }
    }
}